package com.ruoyi.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.VerUser;
import com.ruoyi.service.IVerUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * web user infoController
 * 
 * @author ruoyi
 * @date 2025-08-25
 */
@Api(tags = "web 用户信息管理")
@RestController
@RequestMapping("/api/webUser")
public class VerUserController extends BaseController
{
    @Autowired
    private IVerUserService verUserService;

    /**
     * 查询web user info列表
     */
    @PreAuthorize("@ss.hasPermi('system:user:list')")
    @ApiOperation("查询web user info列表")
    @GetMapping("/list")
    public TableDataInfo list(VerUser verUser)
    {
        startPage();
        List<VerUser> list = verUserService.selectVerUserList(verUser);
        return getDataTable(list);
    }

    /**
     * 获取web user info详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:user:query')")
    @GetMapping(value = "/getInfo/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return success(verUserService.selectVerUserByUserId(userId));
    }

    /**
     * 新增web user info
     */
    @PreAuthorize("@ss.hasPermi('system:user:add')")
    @Log(title = "web user info", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody VerUser verUser)
    {
        return toAjax(verUserService.insertVerUser(verUser));
    }

    /**
     * 修改web user info
     */
    @PreAuthorize("@ss.hasPermi('system:user:edit')")
    @Log(title = "web user info", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody VerUser verUser)
    {
        return toAjax(verUserService.updateVerUser(verUser));
    }

    /**
     * 删除web user info
     */
    @PreAuthorize("@ss.hasPermi('system:user:remove')")
    @Log(title = "web user info", businessType = BusinessType.DELETE)
	@DeleteMapping("/remove/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(verUserService.deleteVerUserByUserIds(userIds));
    }
}
